<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Script-Type" content="text/javascript" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<title>コントロールパネル</title>
		<link rel="stylesheet" href="./assets/styles/default.css" type="text/css" />
		<link rel="stylesheet" href="./assets/styles/ui-lightness/ui.all.css" type="text/css" />
		<link rel="stylesheet" href="./assets/styles/ui-lightness/jquery-ui-1.7.3.custom.css" type="text/css" />
		<link rel="stylesheet" href="./assets/styles/dialog.css" type="text/css" />
		<script src="assets/scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
		<script src="assets/scripts/jquery-ui-1.7.3.custom.min.js" type="text/javascript"></script>
		<script src="assets/scripts/ui/ui.dialog.js" type="text/javascript"></script>
		<script src="assets/scripts/menu.js" type="text/javascript"></script>
		<script src="assets/scripts/table.js" type="text/javascript"></script>
		<script type="text/javascript" src="./assets/scripts/tiny_mce/tiny_mce.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.datepicker.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.core.js"></script>
		<script type="text/javascript" src="./assets/scripts/search.js"></script>
		
		<script type="text/javascript">
		$(function() {
			$('.message').fadeIn("slow");
			$('.btn_regist').click(function(){
				if( confirm('登録してよろしいですか？') ){
					document.fm.mode.value = 'input';
					document.fm.submit();
				}
			});
			
			$('.btn_update').click(function(){
				if( confirm('更新してよろしいですか？') ){
					document.fm.mode.value = 'input';
					document.fm.submit();
				}
			});
			$('.btn_return').click(function(){
				location.href = "minsshop_index.php?hist=2";
			});
			$('.btn_search_del').click(function(){
				var theValue = "";
				var urlPara = makeSearchURL( this.id, theValue );
				{{ if ($isG4) }}
				urlPara = urlPara + "&ins={{ $forms.ins_co_cd }}";
				{{ /if }}
				$("#dialog").load( urlPara ).dialog({
					modal:true
					}); 
				$('#dialog').dialog('open');
			});
			$('.auth').change(function(){
				if (this.value == 4) {
						$('#tr_op4')['show']();
					} else {
						$('#tr_op4')['hide']();
				}
			});
			
			$("#ins_co_cd").change(function(){
				document.fm.ins_co_name.value = $("#ins_co_cd").find("option:selected").text();
			});
			$("#block_cd").change(function(){
				document.fm.block_name.value = $("#block_cd").find("option:selected").text();
			});

			
			$("#local_cd").change(function(){
				document.fm.local_name.value = $("#local_cd").find("option:selected").text();
			});
		
				$('.text_date').datepicker({
					changeMonth: true,
					changeYear: true,
					dateFormat: 'yy/mm/dd'
				});
		});
			//検索画面から戻す値の処理
		var gPara = "";
		function setS( val ) {
			switch (gPara){
				case "media":
					document.fm.media_name.value = val;
					break;
				case "delive":
					document.fm.delive_name.value = val;
					break;
				case "pattern":
					document.fm.pattern_name.value = val;
					break;
				default:
					alert("paramater error");
					return ;
					break;
			}
			$('#dialog').dialog("close");
		}
		
		function setSS( val,name ) {
	
			switch (gPara){
			case "delive":
				document.fm.delive_cd.value = val;
				document.fm.delive_name.value = name;
				break;
			default:
				alert("paramater error");
				return ;
				break;
		}
		$('#dialog').dialog("close");
	}

		</script>
		
	</head>
	<body id="">
{{ $menu }}
{{ $logout }}
		<div id="container"><div class="wrapper">
			<h2>折込販売店マスター管理</h2>
			<ul class="submenu clearfix">
				<li><a href="minsshop_index.php">折込販売店情報一覧</a></li>
				<li>折込販売店情報登録</li>
				<li><a href="minsshop_import.php">CSV更新</a></li>
				{{ if (!$isG5) }} <li><a href="mins_delive_index.php">納品先マスタ</a></li>{{ /if }}
			</ul>
			<h3>折込販売店情報{{ if $forms.id == '' }}登録{{ else }}更新{{ /if }}{{ if $phase == 'complete' }}完了{{ /if }}</h3>
{{ if $phase == 'input' }}
			<p class="message">内容を確認し、{{ if $forms.id == '' }}登録{{ else }}更新{{ /if }}ボタンをクリックしてください。</p>
			<form name="fm" action="minsshop_form.php" method="post">
				<table class="formTable">
					<tbody>
{{ if $forms.id != '' }}
						<tr>
							<th>更新日</th>
							<td>
								{{ $forms.u_time|date_format:"%Y/%m/%d %H:%M" }}<input type="hidden" name="u_time" value="{{ $forms.u_time }}" />
							</td>
						</tr>
						<tr>
							<th>更新者</th>
							<td>
								{{ $forms.m_user_name }}<input type="hidden" name="m_user_name" value="{{ $forms.m_user_name }}" />
							</td>
						</tr>
						<tr>
							<th>ID</th>
							<td>
								{{ $forms.id }}
							</td>
						</tr>
{{ /if }}
{{ if (!$isG5) }} 
						<tr id = "tr_op4" >
							<th><span>※</span>折込会社</th>
							<td>
{{ if ($isG4) }} 
								<input type="text " name="ins_co_name"  class="dtext" value="{{ $forms.ins_co_name }}"  readonly/>
								<input type="hidden" name="ins_co_cd" value="{{ $forms.ins_co_cd }}" />
{{ else }}
	{{ html_options id='ins_co_cd' name='ins_co_cd' options=$ins_co selected=$forms.ins_co_cd }}
								<input type="hidden" name="ins_co_name" value="{{ $forms.ins_co_name }}" />
{{ /if }}
								{{ $err.ins_co_cd }}
							</td>
						</tr>
{{ /if }}
						<tr id = "tr_op4" >
							<th><span>※</span>地域ブロック</th>
							<td>
	{{ html_options id='block_cd' name='block_cd' options=$block selected=$forms.block_cd }}{{ $err.block_cd }}
	<input type="hidden" name="block_name" value="{{ $forms.block_name }}" />
							</td>
						</tr>
						<tr>
							<th><span>※</span>都道府県</th>
							<td>

	{{ html_options id='local_cd' name='local_cd'  options=$local selected=$forms.local_cd }}{{ $err.local_cd }}
	<input type="hidden" name="local_name" value="{{ $forms.local_name }}" />
							</td>
						</tr>
						<tr>
							<th><span>※</span>媒体名</th>
							<td>
								{{ if $forms.id != '' }}
									<!--  <input type="text" name="media_name" class="dtext" value="{{ $forms.media_name|escape }}"  maxlangth="100"   readonly="readonly"/>{{ $err.media_name }}-->
									<input type="text" name="media_name" class="text" value="{{ $forms.media_name|escape }}"  maxlangth="100" />{{ $err.media_name }}
									<button type="button" id="media" class="btn_search" rel="media"><span>参照</span></button>
								{{ else }}
									<input type="text" name="media_name" class="text" value="{{ $forms.media_name|escape }}"  maxlangth="100" />{{ $err.media_name }}
									<button type="button" id="media" class="btn_search" rel="media"><span>参照</span></button>
								{{ /if }}
							</td>
						</tr> <tr>
							<th><span>※</span>GEOコード</th>
							<td>
							{{ if $forms.id != '' }}
								<input type="text" name="ins_shop_cd" value="{{ $forms.ins_shop_cd|escape }}"  maxlangth="20" class="dtext"  readonly="readonly"/>{{ $err.ins_shop_cd }}
							{{ else }}
								<input type="text" name="ins_shop_cd"  value="{{ $forms.ins_shop_cd|escape }}"  maxlangth="20"  class="text" />{{ $err.ins_shop_cd }}
							{{ /if }}
							</td>
						</tr>
						<tr>
							<th><span>※</span>販売店名</th>
							<td>
								<input type="text" name="ins_shop_name"  value="{{ $forms.ins_shop_name|escape }}"  maxlangth="100"  class="text"/>{{ $err.ins_shop_name }}
							</td>
						</tr>
{{ if (!$isG5) }} 
						<tr><th><span>※</span>納品先</th>
							<td>
								<input type="text" name="delive_name" class="text" value="{{ $forms.delive_name|escape }}"  maxlangth="100" />{{ $err.delive_name }}
								<input type="hidden" name="delive_cd" class="text" value="{{ $forms.delive_cd|escape }}"  />
								<button type="button" class="btn_search_del" id="delive"><span>参照</span></button>
							</td>
						</tr>
						<tr><th><span>※</span>折込会社部数</th>
							<td>
								<input type="text" name="insert_conums"  value="{{ $forms.insert_conums|escape }}"  maxlangth="10"  class="text"/>{{ $err.insert_conums }}
							</td>
						</tr>
{{ /if }}
{{ if (!$isG4) }} 
						<tr>
							<th>地域広告有無</th>
							<td>
								{{ html_options id='area_pattern_cd' name='area_pattern_cd'  options=$pattern selected=$forms.area_pattern_cd }}
							</td>
						</tr>
						<tr>
							<th>地域広告部数</th>
							<td>
								<input type="text" name="area_adnums"  value="{{ $forms.area_adnums|escape }}"  maxlangth="10"  class="text"/>{{ $err.area_adnums }}
							</td>
						</tr>
						<tr>
							<th>地域広告備考</th>
							<td>
								<textarea name="area_memo" class="textarea"  style="width:380px" />{{ $forms.area_memo|escape }}</textarea>{{ $err.area_memo }}
							</td>
						</tr>
{{ /if }}
{{ if (!$isG4) &&  (!$isG5)}}
						<tr>
							<th>店舗からの距離</th>
							<td>
								<input type="text" name="shop_away" value="{{ $forms.shop_away|escape }}"  maxlangth="10"  {{ if ($isG4) }} class="dtext"  readonly="readonly" {{ else }} class="text" {{/if}} />{{ $err.shop_away }}
							</td>
						</tr>
						<tr>
							<th>AOKI/競合</th>
							<td>
						{{ if ($isG4) }} 
							<input type="text" name="aoki_compete"  value="{{ $forms.aoki_compete|escape }}"  maxlangth="10" class="dtext"  readonly="readonly" />
						{{ else }}	
						{{ html_options id='aoki_compete' name='aoki_compete' options=$aoki_compete selected=$forms.aoki_compete }}{{ $err.aoki_compete }}
						{{/if}}
							</td>
						</tr>
						<tr>
							<th>世帯普及率</th>
							<td>
								<input type="text" name="home_percent" value="{{ $forms.home_percent }}"  maxlangth="10"  {{ if ($isG4) }} class="dtext"  readonly="readonly" {{ else }} class="text" {{/if}}/>{{ $err.home_percent }}
							</td>
						</tr>
						<tr>
							<th>総需要額</th>
							<td>
								<input type="text" name="all_amount" value="{{ $forms.all_amount|escape }}"  maxlangth="10" {{ if ($isG4) }} class="dtext"  readonly="readonly" {{ else }} class="text" {{/if}}/>{{ $err.all_amount }}
							</td>
						</tr>
						<tr>
							<th>売上高シェア</th>
							<td>
								<input type="text" name="sale_share" value="{{ $forms.sale_share|escape }}"  maxlangth="10" {{ if ($isG4) }} class="dtext"  readonly="readonly" {{ else }} class="text" {{/if}} />{{ $err.sale_share }}
							</td>
						</tr>
{{ /if }}
{{ if (!$isG5)}}
						<tr>
							<th rowspan=2>廃止日</th>
							<td>
								<input type="text" name="stop_date" class="text_date" value="{{ $forms.stop_date }}"  />{{ $err.stop_date }}
							</td>
						</tr>
						<tr><td>
							<textarea name="memo" class="textarea"  style="width:380px" />{{ $forms.memo|escape }}</textarea>{{ $err.memo }}
							</td>
						</tr>
{{ /if }}
					</tbody>
				</table>
				<p class="button">
{{ if $forms.id != '' }}
					<button type="button" class="btn_return" class="submit"><span>戻る</span></button>
					<button type="button" class="btn_update" class="submit"><span>更新</span></button>
{{ else }}
				{{ if !($isG4) }}<button type="button" class="btn_regist" class="submit"><span>登録</span></button>{{ /if }}
{{ /if }}
				</p>
				<input type="hidden" name="id" value="{{ $forms.id }}" />
				<input type="hidden" name="mode" value="" />
			</form>

<div id="dialog" >
</div>
 
{{ /if }}

{{ if $phase == 'complete' }}
			<p class="message">{{ $message }}</p>
			<ul>
{{ if $forms.id != '' }}
				<li>>> <a href="minsshop_index.php?hist=2">一覧ページに戻る</a></li>
{{ else }}
				<li>>> <a href="minsshop_index.php">一覧ページに戻る</a></li>
{{ /if }}
				<li>>> <a href="minsshop_form.php">新規登録</a></li>
{{ if $forms.id != '' }}
				<li>>> <a href="minsshop_form.php?id={{ $forms.id }}">更新</a></li>
{{ /if }}
			</ul>
{{ /if }}

		</div></div>
		{{ $footer }}
	</body>
</html>